<extend name="base/Base" />
<block name="Style">
<!-- FooTable Plugin CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/vendor/plugins/footable/css/footable.core.min.css">
		<!-- Admin Forms CSS  -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/assets/admin-tools/admin-forms/css/admin-forms.css">
		
		<js href="__ADDON__/ueditor/js/jquery-1.11.0.min.js" />
		<js href="__ADDON__/ueditor/cms.admin.config.js" />    
		<js href="__ADDON__/ueditor/ueditor.all.min.js" />
		<script type="text/javascript" src="http://jssdk.demo.qiniu.io/dist/qiniu.min.js"></script>
		<script type="text/javascript" src="/public/addon/style/js/plupload.full.min.js"></script>
		<script>
		$(function(){
			var url="__APP__/Home/Ueditor/Index/Addon/Ueditor.html";
			var ue = UE.getEditor('container',{
				serverUrl :url,
				UEDITOR_HOME_URL:'__ADDON__/ueditor/',
			});
			
			ue.ready(function(){
				ue.execCommand('serverparam', {
					'uid': "<?php echo getUID(); ?>",
				   'username': '<?php echo getUID(); ?>',
				});
			});
		})
		</script>
	
		<js href="__ADDON__/ajaxupload/js/jquery.js" />
		<js href="__ADDON__/ajaxupload/js/ajaxupload.js" />
		<script type="text/javascript">
		$(function(){
			var button = $('#upload_button'), interval;
			var confirmdiv = $('#uploadphotoconfirm');
			var fileType = "pic",fileNum = "one"; 
			new AjaxUpload(button,{
				//action: "__APP__/Home/Upload/Image/Addon/AjaxUpload.html",
				action: "__APP__/CMS/Article/upload.html",
				name: 'userfile',
				onSubmit : function(file, ext){
					if(fileType == "pic")
					{
						if (ext && /^(jpg|png|jpeg|gif|JPG)$/.test(ext)){
							this.setData({
								'info': '文件类型为图片'
							});
						} else {
							 confirmdiv.text('文件格式错误，请上传格式为.png .jpg .jpeg 的图片');
							return false;               
						}
					}
								
					confirmdiv.text('文件上传中');
					
					if(fileNum == 'one')
						this.disable();
					
					interval = window.setInterval(function(){
						var text = confirmdiv.text();
						if (text.length < 14){
							confirmdiv.text(text + '.');                    
						} else {
							confirmdiv.text('文件上传中');             
						}
					}, 200);
				},
				onComplete: function(file, response){
					if(response != "success"){
						if(response =='2'){
							confirmdiv.text("文件格式错误，请上传格式为.png .jpg .jpeg 的图片");
						}else{
							
							confirmdiv.text("上传完成");
							
							$("#newbikephotoName").val(response);
							$("#newbikephoto").attr("src",response);	
							$("#imgurl").attr("value",response);						
							
						}
						
					}
										  
					window.clearInterval(interval);
								
					this.enable();
					
					if(response == "success")
					alert('上传成功');              
				}
			});
		});
		</script>

</block>
<block name="Topbar">
								
 <!-- Start: Topbar -->
      <header id="topbar" class="ph10">
        <div class="topbar-left">
         <ul class="nav nav-list nav-list-topbar pull-left">
           
			<li   class="active" >
              <a href="__APP__/CMS/Article/Create.html"    >新增文章</a>
            </li>
			<li     >
              <a  href="__APP__/CMS/Article/Manage.html"   >文章管理</a>
            </li>
			
           
          </ul>
        </div>
       <!--  <div class="topbar-right hidden-xs hidden-sm">
			<form class="form-inline" action="__APP__/XYZR/Database/MySQL/Backup.html" method="post">
			  <div class="form-group">
				<label for="exampleInputName2">开始时间</label>
				<input type="date" class="form-control" placeholder="请输入开始时间" name="begin_time" value='{$time|time|date="Y-m-d",###}'>
			  </div>
			  <div class="form-group">
				<label for="exampleInputEmail2">结束时间</label>
				<input type="date" class="form-control"  placeholder="请输入开始时间"  name="end_time" value='{$time|time|date="Y-m-d",###}' >
			  </div>
			  <button type="submit" class="btn btn-success">搜索记录</button>
			</form>
        </div>  -->
      </header>
	  						
    				
</block>
<block name="Content">

<!-- START ROW -->

	<div class="row">

		<!-- NEW COL START -->
		<article class="col-md-offset-1 col-sm-12 col-md-12 col-lg-10">
			
			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget" id="wid-id-7" data-widget-editbutton="false" data-widget-custombutton="false">
				<!-- widget options:
					usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
					
					data-widget-colorbutton="false"	
					data-widget-editbutton="false"
					data-widget-togglebutton="false"
					data-widget-deletebutton="false"
					data-widget-fullscreenbutton="false"
					data-widget-custombutton="false"
					data-widget-collapsed="true" 
					data-widget-sortable="false"
				-->
				

				<!-- widget div-->
				<div>
					
					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->
						
					</div>
					<!-- end widget edit box -->
					
					<!-- widget content -->
					<div class="widget-body no-padding">
						
						<form id="smart-form-register" action="__APP__/CMS/Article/Create.html"  enctype="multipart/form-data" method="post" class="smart-form">
							<div id="btn-uploader">
								<a id="pickfiles" href="javascript:void 0;">Upload File</a>
							</div>
							<div class="form-group">
								<label for="exampleInputEmail1">请输入选择文章分类</label>
								<select class="form-control" name="form_id">
								<volist name="list" id="list">
								  <optgroup label="{$list.name}">
								  <if condition="$list.down eq null "> 
									<option value ="{$list.id}">|-- {$list.name}</option>
								  <else /> 
								
									<foreach name="list.down" item="down" >
									<option value ="{$down.id}">|-- {$down.name}</option>
									</foreach>
									  </if>
								  </optgroup>
								</volist>
								
								</select>
							  </div>
							  
							<div class="form-group">
								<label for="exampleInputEmail1">请输入文章标题</label>
								<input type="text"  name="name" id="name" class="form-control"  placeholder="请输入文章信息" value="{$data.name}">
							  </div>
							  <div class="form-group">
								<label for="exampleInputEmail1">请输入文章作者</label>
								<input type="text"  name="author" id="author" class="form-control"  placeholder="请输入文章作者" value="{$data.author}">
							  </div>
							  <div class="form-group">
								<label for="exampleInputEmail1">请输入SEO关键字</label>
								<input type="text"  name="keywords" id="keywords" class="form-control"  placeholder="请输入SEO关键字" value="{$data.keywords}">
							  </div>
							  <div class="form-group">
								<label for="exampleInputEmail1">请输入SEO描述</label>
								<input type="text"  name="description" id="description" class="form-control"  placeholder="请输入SEO描述" value="{$data.description}">
							  </div>
							  <div class="form-group">
								<label for="exampleInputEmail1">请输入简单描述</label>
								<textarea class="form-control" rows="3" name="intro" value="{$data.intro}"></textarea>
								</div>
							  
							   <section>
						<label class="control-label" for="bike_type">&nbsp;</label>
							<input type="file" style="display:none" name="userfile">
							<input type="hidden" id="newbikephotoName" name="img" value="" />
							<input type="hidden" id="oldbikephotoName" value="" />
							<div class="controls" style="text-align:center;">
								<img  id="newbikephoto" src="http://image.zaiyoudao.com/image.php/zyd_126.html" style="max-height:200px;max-width:200px;" />
								<span class="help-inline"></span>
								<br>
								<div id="uploadphotoconfirm"></div>
								<br>
								<input type="hidden" name="img" id="imgurl" value="" style="max-height:200px;max-width:200px;"  >
								<input type="button" class="btn btn-lg btn-primary" style="width:50%" id="upload_button"  value="上传缩略图" /><br/>
								
							</div>
					</section>
						
								
								<section>
									<label for="exampleInputEmail1">请输入文章正文</label>
									
									<label class="input">
									 <script id="container" name="value" type="text/plain"></script>
									 </label>
								</section>
								<br>
								<div class="form-group">
								<label for="exampleInputEmail1">请选择发布时间</label>
								<input style="height:45px;" name="time" placeholder="请输入日期" value='{$time|time|date="Y-m-d",###}' class="form-control laydate-icon gui-input" onclick="laydate()">
								</div>
							</fieldset>
							<br>
							<footer>
								
								<button type="submit" class="btn btn-primary" style="width:100%">
									新增文章
								</button>
							</footer>
								
						</form>						
						
					</div>
					<!-- end widget content -->
					
				</div>
				<!-- end widget div -->
				
			</div>
			<!-- end widget -->	

		</article>
		<!-- END COL -->

		
	<br>
	<br>
	</div>

	<!-- END ROW -->
	
</block>
<block name="Script">
	
  <!-- FooTable Plugin -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.all.min.js"></script>
   <!-- FooTable Addon -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.filter.min.js"></script>

						<script>
			 var uploader = Qiniu.uploader({
                            runtimes: 'html5,flash,html4',    //上传模式,依次退化
                            browse_button: 'pickfiles',       //上传选择的点选按钮，**必需**
                            uptoken_url: '{$token}',            //Ajax请求upToken的Url，**强烈建议设置**（服务端提供）
                            // uptoken : '', //若未指定uptoken_url,则必须指定 uptoken ,uptoken由其他程序生成
                            // unique_names: true, // 默认 false，key为文件名。若开启该选项，SDK为自动生成上传成功后的key（文件名）。
                            // save_key: true,   // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`，则开启，SDK会忽略对key的处理
                            domain: 'http://qiniu-plupload.qiniudn.com/',   //bucket 域名，下载资源时用到，**必需**
                            get_new_uptoken: false,  //设置上传文件的时候是否每次都重新获取新的token
                            container: 'container',           //上传区域DOM ID，默认是browser_button的父元素，
                            max_file_size: '100mb',           //最大文件体积限制
                            flash_swf_url: 'js/plupload/Moxie.swf',  //引入flash,相对路径
                            max_retries: 3,                   //上传失败最大重试次数
                            dragdrop: true,                   //开启可拖曳上传
                            drop_element: 'container',        //拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
                            chunk_size: '4mb',                //分块上传时，每片的体积
                            auto_start: true,                 //选择文件后自动上传，若关闭需要自己绑定事件触发上传
                            init: {
                                'FilesAdded': function(up, files) {
                                    plupload.each(files, function(file) {
                                        // 文件添加进队列后,处理相关的事情
                                    });
                                },
                                'BeforeUpload': function(up, file) {
                                       // 每个文件上传前,处理相关的事情
                                },
                                'UploadProgress': function(up, file) {
                                       // 每个文件上传时,处理相关的事情
                                },
                                'FileUploaded': function(up, file, info) {
                                       // 每个文件上传成功后,处理相关的事情
                                       // 其中 info.response 是文件上传成功后，服务端返回的json，形式如
                                       // {
                                       //    "hash": "Fh8xVqod2MQ1mocfI4S4KpRL6D98",
                                       //    "key": "gogopher.jpg"
                                       //  }
                                       // 参考http://developer.qiniu.com/docs/v6/api/overview/up/response/simple-response.html

                                       // var domain = up.getOption('domain');
                                       // var res = parseJSON(info.response);
                                       // var sourceLink = domain + res.key; 获取上传成功后的文件的Url
                                },
                                'Error': function(up, err, errTip) {
                                       //上传出错时,处理相关的事情
                                },
                                'UploadComplete': function() {
                                       //队列文件处理完毕后,处理相关的事情
                                },
                                'Key': function(up, file) {
                                    // 若想在前端对每个文件的key进行个性化处理，可以配置该函数
                                    // 该配置必须要在 unique_names: false , save_key: false 时才生效

                                    var key = "";
                                    // do something with key here
                                    return key
                                }
                            }
                        });

                        // domain 为七牛空间（bucket)对应的域名，选择某个空间后，可通过"空间设置->基本设置->域名设置"查看获取

                        // uploader 为一个plupload对象，继承了所有plupload的方法，参考http://plupload.com/docs
						
						
						
						
						
						
						
						
						
						
						
							//新增配置
							//新增配置
							function change(){  
							
								var username = $("#username").val();
								var nickname = $("#nickname").val();
								
								var tel = $("#tel").val();
								var email = $("#email").val();
								var img = $("#newbikephotoName").val();
								
								$.ajax({
									type:'POST',
									url:"__APP__/Admin/User/Create.html",
									data:{
										
										"username": username,
										"nickname": nickname,
										"tel": tel,
										"email": email,
										"img": img,
										
										
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
									error:function(){
										layer.msg('系统繁忙,请稍候重试！');
									}
								
								});	 
							}  
							</script>
 <script type="text/javascript">
  jQuery(document).ready(function() {

 

    // Init FooTable Examples
    $('.footable').footable();


  });
  </script>
</block>